package Demo01;

import java.util.ResourceBundle;

class Message {
    private String content;
    public void setContent(String content) {
        this.content = content;
    }
    public String getContent() {
        return content;
    }
}
class MessagePrint {
    public static void print() {
        System.out.println("【MessagePrint】" + Resource.MESSAGES.get().getContent());
    }
}
class Resource {
    public static final ThreadLocal<Message> MESSAGES = new ThreadLocal<>();
}

public class ThreadLocal13 {
    public static void main(String[] args) throws Exception {
       String[] values = new String[] {"沐言科技：www.yootk.com","李兴编程培训营：edu.yootk.com","课程讲师：李兴华"};
       for (String msg : values) {
           new Thread(() -> {
               Resource.MESSAGES.set(new Message());
               Resource.MESSAGES.get().setContent(msg);
               MessagePrint.print();
           }).start();
       }
    }
}
